﻿namespace Community.CsharpSqlite.Entity
{
    /*
    ** The following structure describes the FROM clause of a SELECT statement.
    ** Each table or subquery in the FROM clause is a separate element of
    ** the SrcList.a[] array.
    **
    ** With the addition of multiple database support, the following structure
    ** can also be used to describe a particular table such as the table that
    ** is modified by an INSERT, DELETE, or UPDATE statement.  In standard SQL,
    ** such a table must be a simple name: ID.  But in SQLite, the table can
    ** now be identified by a database name, a dot, then the table name: ID.ID.
    **
    ** The jointype starts out showing the join type between the current table
    ** and the next table on the list.  The parser builds the list this way.
    ** But Build.SrcListShiftJoinType() later shifts the jointypes so that each
    ** jointype expresses the join between the table and the previous table.
    */

    public class SrcList_item
    {
        public ulong colUsed; /* Bit N (1<<N) set if column N of pTab is used */
        public int iCursor; /* The VDBE cursor number used to access this table */
        public byte isPopulated; /* Temporary table associated with SELECT is populated */
        public byte jointype; /* Type of join between this able and the previous */
        public byte notIndexed; /* True if there is a NOT INDEXED clause */
        public Index pIndex; /* Index structure corresponding to zIndex, if any */
        public Expr pOn; /* The ON clause of a join */
        public Select pSelect; /* A SELECT statement used in place of a table name */
        public Table pTab; /* An SQL table corresponding to zName */
        public IdList pUsing; /* The USING clause of a join */
        public string zAlias; /* The "B" part of a "A AS B" phrase.  zName is the "A" */
        public string zDatabase; /* Name of database holding this table */
        public string zIndex; /* Identifier from "INDEXED BY <zIndex>" clause */
        public string zName; /* Name of the table */
    }
}